﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Moq;
using MoqContrib.AutoMock.All.Tests;

namespace MoqContrib.AutoMock.All.Tests.TheContainer
{
    /// <summary>
    /// These tests are really just to prove that everything is pieced together
    /// </summary>
    [TestFixture]
    public abstract class WhenMockingServices<T>
        where T : IDoContainerStuff, IAutoMockContainer, new()
    {
        private T _container;
        private Mock<IAutoMocker> _helper;

        #region Types used for testing
        public interface IService { }
        #endregion

        [SetUp]
        public void Given()
        {
            _helper = new Mock<IAutoMocker>();
            _container = new T();
            _container.Helper = _helper.Object;
            _helper.Setup(x => x.Get<IService>());
        }

        [Test]
        public void I_use_the_generic_helper_for_mocking()
        {
            _container.Mock.Get<IService>();
            _helper.Verify(x => x.Get<IService>());
        }

        [Test]
        public void I_use_the_nongeneric_helper_for_mocking()
        {
            _container.Mock.Get(typeof(IService));
            _helper.Verify(x => x.Get(typeof(IService)));
        }
    }
}
